function initPieChart(title,data,ele){

	var myChart = echarts.init(ele); 
	var option = {
		 /*color:['#FCCE10', '#E87C25','#27727B', '#FE8463','#ff4500'],*/
		 title : {
			text: title,
			subtext: '',
			x:'center'
					},
		tooltip : {
			trigger : 'item',
			formatter : "{a} <br/>{b} : {c} ({d}%)"
		},
		toolbox : {
			show : false,
			feature : {
				mark : {
					show : false
				},
				dataView : {
					show : false,
					readOnly : false
				},
				restore : {
					show : false
				},
				saveAsImage : {
					show : false
				}
			}
		},
		calculable : true,
		series : [{
			name : '所占比例',
			type : 'pie',
			radius : '48%',
			center : [ '50%', '60%' ],
			data : data,
			}]
		};
	
		myChart.setOption(option);
	
	}


function initLineChart(title1,data,dates,name1,ele) {
	var myChart = echarts.init(ele); 
	var option = {
		 title : {
		        text: '',
		        subtext: ''
		    },
		    tooltip : {
		        trigger: 'axis'
		    },
		    legend: {
		        data:title1
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
		            restore : {show: true},
		            saveAsImage : {show: true}
		        }
		    },
		    calculable : true,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : dates
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            'name':name1,
		            splitLine: {show: false}
		        }
		    ],
		    
		    series : data
		};
	
	myChart.setOption(option);
}

function initMapChart(data,ele) {
	var myChart = echarts.init(ele);

	var option = {
		    
		    tooltip : {
		        trigger: 'item'
		    },
		    legend: {
		        orient: 'vertical',
		        x:'left',
		        data:['']
		    },
		    dataRange: {
		        min: 0,
		        max: 300,
		        x: 'left',
		        y: 'bottom',
		        text:['高','低'],           // 文本，默认为数值文本
		        calculable : true
		    },
		    toolbox: {
		        show: true,
//		        orient : 'vertical',
//		        x: 'right',
//		        y: 'center',
		        feature : {
		            mark : {show: false},
		            dataView : {show: false, readOnly: false},
		            restore : {show: true},
		            saveAsImage : {show:true}
		        }
		    },
		    roamController: {
		        show: false,
		        x: 'right',
		        mapTypeControl: {
		            'china': true
		        }
		    },
		    series : [
		        {
		            name: '地域分布',
		            type: 'map',
		            mapType: 'china',
		            roam: false,
		            itemStyle:{
		                normal:{label:{show:true}},
		                emphasis:{label:{show:true}}
		            },
		            data:[
		                {name: '北京',value: data.beijing},
		                {name: '天津',value: data.tianjin},
		                {name: '上海',value: data.shanghai},
		                {name: '重庆',value: data.chongqing},
		                {name: '河北',value: data.hebei},
		                {name: '河南',value: data.henan},
		                {name: '云南',value: data.yunnan},
		                {name: '辽宁',value: data.liaoning},
		                {name: '黑龙江',value: data.heilongjiang},
		                {name: '湖南',value: data.hunan},
		                {name: '安徽',value: data.anhui},
		                {name: '山东',value: data.shandong},
		                {name: '新疆',value: data.xinjiang},
		                {name: '江苏',value: data.jiangsu},
		                {name: '浙江',value: data.zhejiang},
		                {name: '江西',value: data.jiangxi},
		                {name: '湖北',value: data.hubei},
		                {name: '广西',value: data.guangxi},
		                {name: '甘肃',value: data.gansu},
		                {name: '山西',value: data.shanxi1},
		                {name: '内蒙古',value: data.neimenggu},
		                {name: '陕西',value: data.shanxi2},
		                {name: '吉林',value: data.jilin},
		                {name: '福建',value: data.fujian},
		                {name: '贵州',value: data.guizhou},
		                {name: '广东',value: data.guangdong},
		                {name: '青海',value: data.qinghai},
		                {name: '西藏',value: data.xizang},
		                {name: '四川',value: data.sichuan},
		                {name: '宁夏',value: data.ningxia},
		                {name: '海南',value: data.hainan},
		                {name: '台湾',value: data.taiwan},
		                {name: '香港',value: data.xianggang},
		                {name: '澳门',value: data.aomen}
		              
		            ]
		        }
		    ]
		};

	myChart.setOption(option);
}

function initTreeChart(data,ele) {
	var myChart = echarts.init(ele);

	var option = {
		    /*title : {
		        text: '树图',
		        subtext: '虚构数据'
		    },*/
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: true, readOnly: true},
		            restore : {show: true},
		            saveAsImage : {show: true}
		        }
		    },
		   /* textStyle :{
		    	baseline : bottom,//'top' | 'bottom' | 'middle' 
		    	fontStyle: normal //normal' | 'italic' | 'oblique'
		    },*/
		    
		    calculable : true,

		    series : [
		        {
		            name:'树图',
		            type:'tree',
		            orient: 'horizontal',  // vertical horizontal  radial
		            rootLocation: {x: 100, y: 'center'}, // 根节点位置{x: 'center',y: 50}  {x: 100, y: 'center'}
		            roam:false,//能否拖动缩放
		            nodePadding: 1,
		           nodePadding: 35,
		           
		            itemStyle: {
		                normal: {
		                	
		                   label:{
		                	   show: true,
		                	   position:'top'
		                   },
		                    lineStyle: {
		                        color: '#48b',
		                        shadowColor: '#000',
		                        shadowBlur: 3,
		                       
		                        shadowOffsetX: 3,
		                        shadowOffsetY: 5,
		                        type: 'broken' // 'curve'|'broken'|'solid'|'dotted'|'dashed'

		                    }
		                },
		                emphasis: {
		                    label: {
		                        show: true,
		                        position:'bottom',
		                    }
		                }
		            },
		            data:  data
			                
		        }
		    ]
		};
	
	myChart.setOption(option);
}

function initStackBarChart(title,data,dates,name1,name2,ele) {
	
          var myChart = echarts.init(ele);

      	var option = {
      		    
      		    tooltip : {
      		        trigger: 'axis'
      		    },
      		    legend: {
      		        data:title
      		    },
      		    toolbox: {
      		        show : true,
      		        feature : {
      		            mark : {show: false},
      		            dataView : {show: true, readOnly: false},
      		            magicType : {show: true, type: ['line', 'bar']},
      		            restore : {show: true},
      		            saveAsImage : {show: true}
      		        }
      		    },
      		    calculable : true,
      		    xAxis : [
      		        {
      		            type : 'category',
      		            data : dates
      		        }
      		    ],
      		    yAxis : [
      	              {
      	                  'type':'value',
      	                  'name':name1,
      	                  //'max':53500
      	                  splitLine: {show: false}
      	              },
      	              {
      	                  'type':'value',
      	                  'name':name2,
      	                  'max':100,
      	                  splitLine: {show: false}
      	              }
      	          ],
      		    series :  data
      		    
      		};
	
	myChart.setOption(option);
}

function initBarChart(title,data,dates,name1,ele) {
	var myChart = echarts.init(ele);

	var option = {
		    
		    tooltip : {
		        trigger: 'axis'
		    },
		    legend: {
		        data:title
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: true, readOnly: false},
		            magicType : {show: true, type: ['line', 'bar']},
		            restore : {show: true},
		            saveAsImage : {show: true}
		        }
		    },
		    calculable : true,
		    xAxis : [
		        {
		            type : 'category',
		            data : dates
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value',
		            'name':name1,
		            splitLine: {show: false}
		        }
		    ],
		    series : data
		};
	
	myChart.setOption(option);
}


function initFFFLineChart(title,data,ele) {
	var myChart = echarts.init(ele); 
	var option = {
		    tooltip : {
		        trigger: 'axis'
		    },
		    legend: {
		        data:['每月工资']
		    },
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: false},
		            dataView : {show: true, readOnly: false},
		            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
		            restore : {show: true},
		            saveAsImage : {show: true}
		        }
		    },
		    calculable : true,
		    xAxis : [
		        {
		            type : 'category',
		            boundaryGap : false,
		            data : ['2017-1','2017-2','2017-3','2017-4','2017-5','2017-6','2017-7','2017-8','2017-9','2017-10','2017-11','2017-12']
		        }
		    ],
		    yAxis : [
		        {
		            type : 'value'
		        }
		    ],
		    series : [
		        {
		            name:'每月工资',
		            type:'line',
		            stack: '总量',
		            data:[1200, 1320, 1010, 1340, 900, 2300, 3000,2100, 1320, 2010, 3340, 2900]
		        }
		    ]
		};
	
	myChart.setOption(option);
}




/**
 * 
 * @param data
 * @param ele
 * 
 * 树形图 和 饼图 结合
 */
        function initMap(data,ele) {
            // 基于准备好的dom，初始化echarts图表
            //var myChart = ec.init(document.getElementById('main')); 
            var myChart = echarts.init(ele);
            var option = {
            	   /* title : {
            	        text: '2011全国GDP（亿元）',
            	        subtext: '数据来自国家统计局'
            	    },*/
            	    tooltip : {
            	        trigger: 'item'
            	    },
            	    legend: {
            	        x:'right',
            	        selectedMode:false,
            	        data:['北京','上海','天津']
            	    },
            	    dataRange: {
            	        orient: 'horizontal',
            	        min: 0,
            	        max: 55000,
            	        text:['高','低'],           // 文本，默认为数值文本
            	        splitNumber:0
            	    },
            	    toolbox: {
            	        show : true,
            	        orient: 'vertical',
            	        x:'right',
            	        y:'center',
            	        feature : {
            	            mark : {show: false},
            	            dataView : {show: true, readOnly: false},
            	            restore : {show: true},
        		            saveAsImage : {show: true}
            	        }
            	    },
            	    series : [
            	        {
            	            name: '员工人数分布',
            	            type: 'map',
            	            mapType: 'china',
            	            mapLocation: {
            	                x: 'left'
            	            },
            	            selectedMode : 'multiple',
            	            itemStyle:{
            	                normal:{label:{show:true}},
            	                emphasis:{label:{show:true}}
            	            },
            	            data:[
            	                  
								{name: '北京',value: data.beijing, selected:true},
								{name: '天津',value: data.tianjin, selected:true},
								{name: '上海',value: data.shanghai, selected:true},
								{name: '重庆',value: data.chongqing},
								{name: '河北',value: data.hebei},
								{name: '河南',value: data.henan},
								{name: '云南',value: data.yunnan},
								{name: '辽宁',value: data.liaoning},
								{name: '黑龙江',value: data.heilongjiang},
								{name: '湖南',value: data.hunan},
								{name: '安徽',value: data.anhui},
								{name: '山东',value: data.shandong},
								{name: '新疆',value: data.xinjiang},
								{name: '江苏',value: data.jiangsu},
								{name: '浙江',value: data.zhejiang},
								{name: '江西',value: data.jiangxi},
								{name: '湖北',value: data.hubei},
								{name: '广西',value: data.guangxi},
								{name: '甘肃',value: data.gansu},
								{name: '山西',value: data.shanxi1},
								{name: '内蒙古',value: data.neimenggu},
								{name: '陕西',value: data.shanxi2},
								{name: '吉林',value: data.jilin},
								{name: '福建',value: data.fujian},
								{name: '贵州',value: data.guizhou},
								{name: '广东',value: data.guangdong},
								{name: '青海',value: data.qinghai},
								{name: '西藏',value: data.xizang},
								{name: '四川',value: data.sichuan},
								{name: '宁夏',value: data.ningxia},
								{name: '海南',value: data.hainan},
								{name: '台湾',value: data.taiwan},
								{name: '香港',value: data.xianggang},
								{name: '澳门',value: data.aomen}
            	                
            	            ]
            	        },
            	        {
            	            name:'员工人数',
            	            type:'pie',
            	            roseType : 'area',
            	            tooltip: {
            	                trigger: 'item',
            	                formatter: "{a} <br/>{b} : {c} ({d}%)"
            	            },
            	            center: [ele.offsetWidth - 250, 225],
            	            radius: [30, 120],
            	            data:[
								{name: '北京',value: data.beijing},
								{name: '天津',value: data.tianjin},
								{name: '上海',value: data.shanghai}
            	            ]
            	        }
            	    ],
            	    animation: false
            	};
            	//var ecConfig = require('echarts/config');
            	//console.log(ecConfig.EVENT.MAP_SELECTED);
            	myChart.on('mapSelected', function (param){
            	    var selected = param.selected;
            	    var mapSeries = option.series[0];
            	    var data = [];
            	    var legendData = [];
            	    var name;
            	    for (var p = 0, len = mapSeries.data.length; p < len; p++) {
            	        name = mapSeries.data[p].name;
            	        //mapSeries.data[p].selected = selected[name];
            	        if (selected[name]) {
            	            data.push({
            	                name: name,
            	                value: mapSeries.data[p].value
            	            });
            	            legendData.push(name);
            	        }
            	    }
           
            	    option.legend.data = legendData;
            	    option.series[1].data = data;
            	    myChart.setOption(option, true);
            	});
    
            // 为echarts对象加载数据 
            myChart.setOption(option); 
            
        };

    
        function force(data,ele) {
        	
        	
        	function mock(parentNode, depth) {
                var nChildren = Math.round(rangeRandom(constMinChildren, constMaxChildren));
                
                for (var i = 0; i < nChildren; i++) {
                    var childNode = createRandomNode(depth);
                    links.push({
                        source : parentNode.id,
                        target : childNode.id,
                        weight : 1 
                    });
                    if (depth < constMaxDepth) {
                        mock(childNode, depth + 1);
                    }
                }
            }

        
        	
        	
        	
        	
        	
        	
        	
        	
        	
        	
        	
        	var myChart = echarts.init(ele);
			var option = {
				    title : {
				        text: 'Force',
				        subtext: 'Force-directed tree',
				        x:'right',
				        y:'bottom'
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: '{a} : {b}'
				    },
				    toolbox: {
				        show : true,
				        feature : {
				            restore : {show: true},
				            magicType: {show: true, type: ['force', 'chord']},
				            saveAsImage : {show: true}
				        }
				    },
				    legend: {
				        x: 'left',
				        data:['叶子节点','非叶子节点', '根节点']
				    },
				    series : [
				        {
				            type:'force',
				            name : "Force tree",
				            ribbonType: false,
				            categories : [
				                {
				                    name: '叶子节点',
				                    itemStyle: {
				                        normal: {
				                            color : '#ff7f50'
				                        }
				                    }
				                },
				                {
				                    name: '非叶子节点',
				                    itemStyle: {
				                        normal: {
				                            color : '#6f57bc'
				                        }
				                    }
				                },
				                {
				                    name: '根节点',
				                    itemStyle: {
				                        normal: {
				                            color : '#af0000'
				                        }
				                    }
				                }
				            ],
				            itemStyle: {
				                normal: {
				                    label: {
				                        show: false
				                    },
				                    nodeStyle : {
				                        brushType : 'both',
				                        strokeColor : 'rgba(255,215,0,0.6)',
				                        lineWidth : 1
				                    }
				                }
				            },
				            minRadius : 2,
				            maxRadius : 10,
				            nodes : data,
				            links : links
				        }
				    ]
				};
			
			 // 为echarts对象加载数据 
            myChart.setOption(option); 
            
		}
        
